﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using DTcms.Common;

namespace DTcms.Web
{
    public partial class Layout : System.Web.UI.Page
    {
        protected DataTable dtMenu = null;
        protected string connnt = "";
       protected int x = 0;
       protected int _id = DTRequest.GetQueryInt("id");
        protected int count = 0;
        protected double n= 0.0;
        protected string id = "";
        protected void Page_Load(object sender, EventArgs e)
        {

            //int _id = DTRequest.GetQueryInt("id");
            int _aid = DTRequest.GetQueryInt("aid");
            id = _id.ToString();
            rptTeam.DataSource = new BLL.article_category().GetList(57, 2);
            rptTeam.DataBind();

            if (_id != 0)
            {
                Model.article_category model = new BLL.article_category().GetModel(_id);
                Model.article_category modelP = new BLL.article_category().GetModel(model.parent_id);
                StringBuilder html = new StringBuilder();
                html.Append("<a href=\"/index.aspx\">主页</a>");
                if (modelP != null)
                {
                    html.Append("> <a href=\"" + modelP.link_url + "\">" + modelP.title + "</a>");
                }
                if (model != null)
                {
                    html.Append("> <a href=\"" + model.link_url + "?id=" + model.id + "\">" + model.title + "</a>");
                }
                memu.InnerHtml = html.ToString();
            }
           
                count = new BLL.article().GetCount("category_id="+ _id);
                Repeater1.DataSource = new BLL.article().GetList(4,"channel_id=2 and category_id="+_id, "sort_id,add_time desc");
                Repeater1.DataBind();
            n = Convert.ToDouble(count) / 4;
            if (x + 1 > n) { LinkButton1.Visible =false; }
            else { LinkButton1.Visible = true; }
       

        }

        protected void Button1_Click(object sender, EventArgs e)
        {if (x<=count)
            { x = x + 1; }
            Repeater1.DataSource = new BLL.article().GetList(4+x*4,"channel_id = 2 and category_id = "+_id, "sort_id,add_time desc");
            //Repeater1.DataSource = new BLL.article().GetList(2, _id, 4, x+1, "", "sort_id,add_time desc", out count);
            Repeater1.DataBind();
            if (x + 1 > n) { LinkButton1.Visible = false; }
            else { LinkButton1.Visible = true; }

        }
    }
}